package org.zr.api;

import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.zr.api.impl.TestApiImpl;

import java.util.HashMap;
import java.util.Map;

public class ServiceConsumer {
    public static void main(String[] args) {
        ApplicationConfig applicationConfig = new ApplicationConfig();
        applicationConfig.setName("consumer-api");

        RegistryConfig registryConfig = new RegistryConfig();
        Map<String, String> params = new HashMap<>();
        params.put("qos.enable", "false");
        registryConfig.setParameters(params);
        registryConfig.setAddress("zookeeper://127.0.0.1:2181");
        ReferenceConfig<TestApi> api = new ReferenceConfig<>();
        api.setInterface(TestApi.class);
        api.setRegistry(registryConfig);
        api.setApplication(applicationConfig);
        TestApi apiImpl = api.get();
        System.out.println(apiImpl);
        String world = apiImpl.helloWorld("zr");
        System.out.println(world);
    }
}
